import java.util.Random;
import java.util.Scanner;

public class Test {
    public static void main8(String[] args) {
        //编写程序数一下 1到 100 的所有整数中出现多少个数字9
        int i=0;
        int num=0;
        int count=0;

        for(i=1;i<=100;i++){
            num=i%10;
            if(num==9)
            {
                count++;
            }
            if(i/10==9){
                count++;
            }
        }
        System.out.println("1到 100 的所有整数中出现"+count+"个数字9");
    }
    public static void main7(String[] args) {
        //猜数字游戏
        Random random=new Random();
        int guess= random.nextInt(100);//生成随机数[0~100)

        Scanner scanner=new Scanner(System.in);

        while (true){
            System.out.println("请输入你猜的数字：");
            int num= scanner.nextInt();
            if(num>guess){
                System.out.println("猜大了！");
            }else if(num<guess){
                System.out.println("猜小了！");
            }else{
                System.out.println("猜对了！");
                break;
            }
        }
    }
    public static void main6(String[] args) {
        //循环输入
        Scanner scanner=new Scanner(System.in);

        while(scanner.hasNextInt()){//ctrl+d：结束输入
            int a= scanner.nextInt();
            System.out.println(a);

        }
    }
    public static void main5(String[] args) {
        //输入
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入你的年龄:");
        int age= scanner.nextInt();
        System.out.println("年龄："+age);

        scanner.nextLine();//把回车识别输入

        System.out.println("请输入你的名字:");
        String name=scanner.nextLine();
        //String name= scanner.next();//遇到空格结束
        System.out.println("名字："+name);

        //scanner.nextLine();//前面是字符串，就不要写这条语句

        System.out.println("请输入你的体重:");
        double h= scanner.nextDouble();
        System.out.println("体重："+h);
    }
    public static void main4(String[] args) {
        //1~100中，找出既能被3整除，又能被5整除的所有数字
        int i=1;
        while(i<=100){
            if(i%15!=0){
                i++;
                continue;
            }
            System.out.println(i);
            i++;
        }
    }
    public static void main3(String[] args) {
        //循环，求n的阶乘,1!+2!+3!+...
        Scanner scanner=new Scanner(System.in);
        int n= scanner.nextInt();
        int i=1;
        int j=1;
        int ret=1;
        int sum=0;
        while(j<=n){
            i=1;
            ret=1;
            while(i<=j)
            {
                ret*=i;
                i++;
            }
            sum+=ret;
            j++;
        }
        System.out.println(sum);
    }
    public static void main2(String[] args) {
        //switch
        int a=1;
        switch(a){
            case 1:
                System.out.println("1");
                break;
            case 2:
                System.out.println("2");
                break;
            case 3:
                System.out.println("3");
                break;
            default:
                System.out.println("4");
                break;
        }

    }
    public static void main1(String[] args) {
        //判断是不是偶数,if语句
        Scanner scanner=new Scanner(System.in);
        int a=scanner.nextInt();
        if(a%2==0){
            System.out.println("是偶数");
        }else{
            System.out.println("不是偶数");
        }

    }
}
